<%--
  Created by IntelliJ IDEA.
  User: lingshao
  Date: 2020/9/19
  Time: 11:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>班级信息</title>
    <%--    引入layer--%>
    <script src="../jQuery/jquery-1.11.2.js"></script>
    <link rel="stylesheet" href="../layui/layui/css/layui.css" media="all">
    <script src="../layer/layer/layer.js"></script>

    <script src="../layui/layui/layui.js"></script>
    <style type="text/css">
        .layui-table-cell{
            height:36px;
            line-height: 36px;
        }
        *{
            font-size: 20px;
            font-family: 微软雅黑;
        }
    </style>

</head>
<body>

<blockquote class="layui-elem-quote news_search">

    <div class="demoTable" id="demoTableId" hidden="true">
        <form class="layui-form">
            <div style="float: right;margin-right: 150px;">
                <a class="layui-btn layui-btn-radius layui-icon layui-icon-add-circle " lay-event="okk" style="font-size: 20px;">更新试题难度</a>
            </div>
        </form>
    </div>
    <%--展示表格--%>
    <table id="demo" lay-filter="test"></table>
</blockquote>


<script type="text/javascript">
    layui.use(['table','layer','form'], function(){
        var table = layui.table;
        var layer=layui.layer;
        var form=layui.form;
        //定义一个编号，便于后期关闭div对话框
        var closeDiv;
        //第一个实例，渲染表格
        table.render({
            elem: '#demo'
            ,cellMinWidth: 80
            ,height:665
            ,toolbar:"#demoTableId"
            ,url: '../AnalysisServlet?method=findAll' //数据接口
            , limits: [5,10,15,20]  //一页选择显示3,5或10条数据
            , limit: 5  //一页显示10条数据
            // , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据，res为从url中get到的数据
            //     var result;
            //     if (this.page.curr) {
            //         result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
            //     }
            //     else {
            //         result = res.data.slice(0, this.limit);
            //     }
            //     return {
            //         "code": res.code, //解析接口状态
            //         "msg": res.msg, //解析提示文本
            //         "count": res.count, //解析数据长度
            //         "data": result //解析数据列表
            //     };
            // }
            ,cols: [[ //表头
                {type:"checkbox",fixed: "left" ,style: "50px"}
                ,{field: 'analyId',style:"font-size:20px", title: '编号', align: 'center', fixed: 'left'}
                ,{field:'paperId',style: "font-size:20px",title: '试卷编号',align: 'center'}
                ,{field: 'subjectId',style:"font-size:20px", title: '试题编号', align: 'center'}
                ,{field: 'className',style:"font-size:20px", title: '班级名称', align: 'center'
                    // ,templet:function (d) {
                    //     if (d.classId==1){
                    //         return'<span>t281</span>';
                    //     }else if (d.classId==2){
                    //         return'<span>t282</span>';
                    //     }else if (d.classId==3) {
                    //         return '<span>t283</span>';
                    //     }else if (d.classId==4) {
                    //         return '<span>t285</span>';
                    //     }else if (d.classId==5) {
                    //         return '<span>t286</span>';
                    //     }else if (d.classId==6) {
                    //         return '<span>t287</span>';
                    //     }
                    // }
                    }
                ,{field: 'rightNum',style:"font-size:20px", title: '本题正确人数', align: 'center'}
                ,{field: 'accRate',style:"font-size:20px", title: '正确率', align: 'center'}
            ]]
            ,page:true
        });
        //判断点击的是刷新页面
        table.on("toolbar(test)",function (data) {
            //判断点击的是刷新页面
            if (data.event == "okk") {
                var data1=layui.table.cache['demo'];
                $.each(data1,function(index,item){
                    delete item['LAY_TABLE_INDEX'];
                    $.ajax({
                        async:false,
                        url:"../AnalysisServlet?method=updateSubjectAnalysis",
                        type:"POST",
                        data:"json="+JSON.stringify(item),
                        success:function(data){

                        }
                    });
                });
                table.reload('demo');
            }
        });
    });
</script>
</body>
</html>

